#pragma once

#include "WeaponDlg.h"
#include "ProgressBarDialog.h"
#include "afxwin.h"

#define EXPL_LOAD   "\\expl.ini"
#define EXPL_SAVE   "\\expl.ini"

#define ARMOUR_LOAD   "\\armour.ini"
#define ARMOUR_SAVE   "\\armour.ini"

#define MAX_EXPL_ALIASES 16
#define MAX_ARMOUR_ALIASES 32

const UINT8 DefArmClass         = 0xFF;
const UINT8 DefArmProtection    = 0;
const UINT8 DefArmDegradePcnt   = 0;
const UINT8 DefExplClass        = 0xFF;
const UINT8 DefExplDamage       = 0;
const UINT8 DefExplStunDamage   = 0;
const UINT8 DefExplRadius       = 1;
const UINT8 DefExplVolume       = 0;
const UINT8 DefExplVolatility   = 0;

// CExpl_Arm dialog

class CExpl_Arm : public CDialog
{
	DECLARE_DYNAMIC(CExpl_Arm)
  
public:
	CExpl_Arm(CWnd* pParent = NULL);   // standard constructor
	virtual ~CExpl_Arm();

// Dialog Data
	enum { IDD = IDD_EXPL_ARM };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
private:
  enum
  {
    NORMAL     = 0,
    STUN       = 1,
    TEARGAS    = 2,
    MUSTGAS    = 3,
    FLARE      = 4,
    NOISE      = 5,
    SMOKE      = 6,
    CREATUREGAS= 7,
    MAX_ECS 
  };

  enum
  {
    NO_BLAST,
    BLAST_1,
    BLAST_2,
    BLAST_3,
    STUN_BLAST,	
    WATER_BLAST,
    TARGAS_EXP,
    SMOKE_EXP,
    MUSTARD_EXP,
    NUM_EXP_TYPES
  };

  enum
  {
    HELMET  = 0,
    VEST    = 1,
    LEGGINGS= 2,
    PLATE   = 3,
    MONST   = 4,
    VEHICLE = 5,
  };

private:
  bool m_bSavedExpl;
  bool m_bSavedArm;
  COXToolTipCtrl m_tooltip;
public:
  bool IsSaved( bool Expl ) const { return Expl ? m_bSavedExpl : m_bSavedArm; }
  /************************************************************************/
  /* Variables                                                            */
  /************************************************************************/
  ARMOURTYPE  Armour[ MAX_ARMOUR_TYPES ];
  ARMOURTYPE *pCurArmour;
  UINT8       m_ui8ArmUsed;
  EXPLOSIVETYPE  Explosive[ MAX_EXPLOSIVE_TYPES ];
  EXPLOSIVETYPE *pCurExpl;
  UINT8           m_ui8ExplUsed;

  TCHAR ExplosiveAliases[MAX_EXPL_ALIASES][MAX_EXPLOSIVE_CLASS_ALIAS];
  TCHAR ArmourAliases[MAX_ARMOUR_ALIASES][MAX_ARMOUR_CLASS_ALIAS];

  CWeaponDlg *pWeapDlg;
  CItemsDlg *pItemsDlg;
  /************************************************************************/
  /* Methods                                                              */
  /************************************************************************/
  void SetClassPointers(ClassPointers *p);
  int Load( CProgressBarDialog *pProgressDialog );
  int Save( bool Expl );

  void FillArmour();
  void SaveArmour();
  void FillExplosives();
  void SaveExplosives();

  int GetExplIniSettings( CProgressBarDialog *pProgressDialog );
  int GetArmourIniSettings( CProgressBarDialog *pProgressDialog );
  //Explosives
  char *GetECNameByID( int nID );
  int GetECIDByName( const char * );

  int GetAnimationIdByName(LPCTSTR tsClass);
  char *GetAnimationNameByID( int nID );

  //Armour
  char *GetArmourNameByID( int nID );
  int GetArmourIDByName( const char * );

private:
  CListBox m_lbArmours;
  CListBox m_lbExplosives;
  CComboBox m_cbArmourClass;
  CComboBox m_cbExplAnimationID;
  CComboBox m_cbExplosiveClass;
public:
  afx_msg void OnLbnSelchangeListArmours();
  afx_msg void OnCbnSelchangeAmrourClass();
  afx_msg void OnEnChangeArmProtection();
  afx_msg void OnEnChangeArmDegradePct();
  afx_msg void OnLbnSelchangeListExplosives();
  afx_msg void OnCbnSelchangeExplosiveClass();
  afx_msg void OnEnChangeExplDamage();
  afx_msg void OnEnChangeExplStundamage();
  afx_msg void OnEnChangeExplRadius();
  afx_msg void OnEnChangeExplVolume();
  afx_msg void OnEnChangeExplVolatility();
  afx_msg void OnCbnSelchangeExplosiveAnimId();
  void OnOK() {};
  void OnCancel() {};

  BOOL PreTranslateMessage(MSG* pMsg) 
  {
    if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST)
      m_tooltip.RelayEvent(pMsg);

    return CDialog::PreTranslateMessage(pMsg);
  }
};
